package com.wms.controller;

import com.wms.bean.ResultBean;
import com.wms.core.R;
import com.wms.minio.MinioPojo;
import com.wms.minio.MinioService;
import com.wms.service.TuPianService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

@RestController
@Api(tags = {"王奥鑫图片测试"})
public class TuPianContorller {
    @Autowired
    TuPianService tuPianService;
    @Autowired
    MinioService minioService;
    @Autowired
    private MinioPojo minio;

    @ApiOperation("图片上传minio并保存地址")
    @PostMapping(value = "/waxTupian" ,consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public ResultBean upload(@RequestParam("file") MultipartFile file){
        String url =tuPianService.upload(minio.getBucketName(),file);
        return R.success("文件上传", url);
    }

    @ApiOperation("图片信息查询")
    @GetMapping("/waxSelectTP")
    public ResultBean selectTP(){
        List<Map> list=tuPianService.selectTu();
        return R.success("图片查询", list);
    }


}
